package com.server.servlet.user;

import java.util.List;

import com.bean.Message;
import com.bean.User;
import com.server.servlet.Servlet;
import com.server.util.XmlParseHelper;

public class LoginServlet extends Servlet {

	@Override
	public void receiveMessage(Message msg) {
		User user = msg.getUser();
		List<User> allUsers = XmlParseHelper.getAll("user.xml", User.class);
		for(User u : allUsers) {
			if(user.getUsername().equals(u.getUsername()) 
					&& user.getPassword().equals(u.getPassword())) {
				user.setResponsType(u.getResponsType());
				msg.setRespCode("3");
				msg.setRespDes("登陆成功!!!");
				break;
			} else {
				msg.setRespCode("0");
				msg.setRespDes("账号或密码错误!!!");
			}
		}
		msg.setUser(user);
	}
	
}
